function [h0,h1,g0,g1] = atrousfilters(fname);
% ATROUSFILTERS	Generate pyramid 2D filters
%
%	[h0, h1, g0, g1] = atrousfilters(fname, type)
%
%   Input:
%	fname:	Filter name.  Available 'fname' are:
%		'9-7':		    Filters obtained from 9-7 1-D prototypes
%		'maxflat':		Filters derived from 1-D using maximally flat mapping function with 4 vanishing moments
%		'pyr':		    Filters derived from 1-D using maximally flat mapping function with 2 vanishing moments
%		'pyrexc':		Same as pyr but exchanging two highpass filters

%   Output:
%	h0, h1, g0, g1:	pyramid filters for 2-D nonsubsampled filter bank (lowpass and highpass)

%   To test those filters (for the PR condition for the FIR case), verify that:
%   conv2(h0,g0) + conv2(g1, h1) = 1
%   (replace + with - for even size filters)
 
%   the filters have horizontal/vertical/diagonal symetry and can be implemented with
%   symetric extension. 
%   filters designed by A. Cunha, May 2004 (see Tech Report, University of Illinois, Set 2004, av. upon req.)
%   SEE ALSO: dfilters, nsscdec


switch fname
case '9-7'
    % Filters derived from 9-7 prototypes, frame bounds A=0.91, B=1.101
h0 = [0.00010448733363597687 0.000835898669087815   0.0029256453418073525  0.005851290683614705    0.007314113354518382 ...
      0.005851290683614705   0.0029256453418073525  0.000835898669087815   0.00010448733363597687;    
      0.000835898669087815   0.003080092825681339   0.001762583572331734  -0.007296122436400075 ...
     -0.013629023704276572  -0.007296122436400075   0.001762583572331734   0.003080092825681339    0.000835898669087815 ;
      0.0029256453418073525  0.001762583572331734  -0.01306636838062783   -0.02131840020457929    -0.018830187186854155 ...
     -0.02131840020457929   -0.01306636838062783    0.001762583572331734   0.0029256453418073525;
      0.005851290683614705  -0.007296122436400075  -0.02131840020457929    0.0740121520471188      0.16436627826336664 ...
      0.0740121520471188    -0.02131840020457929   -0.007296122436400075   0.005851290683614705;
      0.007314113354518382  -0.013629023704276572  -0.018830187186854155   0.16436627826336664     0.3245066567828517  0.16436627826336664 ...
     -0.018830187186854155  -0.013629023704276572   0.007314113354518382;  
      0.005851290683614705  -0.007296122436400075  -0.02131840020457929    0.0740121520471188      0.16436627826336664 ...
      0.0740121520471188    -0.02131840020457929   -0.007296122436400075   0.005851290683614705;
      0.0029256453418073525  0.001762583572331734  -0.01306636838062783   -0.02131840020457929    -0.018830187186854155 ...
     -0.02131840020457929   -0.01306636838062783    0.001762583572331734   0.0029256453418073525;    
      0.000835898669087815   0.003080092825681339   0.001762583572331734 ...
     -0.007296122436400075  -0.013629023704276572  -0.007296122436400075 0.001762583572331734      0.003080092825681339 0.000835898669087815; 
      0.00010448733363597687 0.000835898669087815   0.0029256453418073525 ...
      0.005851290683614705   0.007314113354518382   0.005851290683614705 0.0029256453418073525     0.000835898669087815 0.00010448733363597687];
    
h1= [0.0014261212986601578    0.008556727791960947    0.021391819479902367    0.028522425973203154 ...
     0.021391819479902367     0.008556727791960947    0.0014261212986601578;  
     0.008556727791960947     0.01351698519464063    -0.022942609349085995  ...    
    -0.055805733503531366    -0.022942609349085995    0.01351698519464063     0.008556727791960947; 
     0.021391819479902367    -0.022942609349085995   -0.1692097602584649     -0.24975066285895303    -0.1692097602584649 ...
    -0.022942609349085995     0.021391819479902367; 
     0.028522425973203154    -0.055805733503531366   -0.24975066285895303     1.669154993235563      -0.24975066285895303      ...
    -0.055805733503531366     0.028522425973203154; 
     0.021391819479902367    -0.022942609349085995   -0.1692097602584649     -0.24975066285895303  ...    
    -0.1692097602584649      -0.022942609349085995    0.021391819479902367  ; 
     0.008556727791960947     0.01351698519464063    -0.022942609349085995   -0.055805733503531366   ...
    -0.022942609349085995     0.01351698519464063     0.008556727791960947  ; 
     0.0014261212986601578    0.008556727791960947    0.021391819479902367    0.028522425973203154 ...   
     0.021391819479902367     0.008556727791960947    0.0014261212986601578 ];
 
 
 g0= [-0.0014261212986601578      -0.008556727791960947    -0.021391819479902367      -0.028522425973203154 ...     
      -0.021391819479902367       -0.008556727791960947    -0.0014261212986601578;
      -0.008556727791960947       -0.020709925973203154    -0.005829153765164099       0.012648088832156207...
      -0.005829153765164099       -0.020709925973203154    -0.008556727791960947; 
      -0.021391819479902367       -0.005829153765164099     0.1692097602584649         0.3072941890874532 ...    
       0.1692097602584649         -0.005829153765164099    -0.021391819479902367; 
      -0.028522425973203154        0.012648088832156207     0.3072941890874532         0.5322473485641878 ...    
       0.3072941890874532          0.012648088832156207    -0.028522425973203154 ; 
      -0.021391819479902367       -0.005829153765164099     0.1692097602584649         0.3072941890874532 ...   
       0.1692097602584649         -0.005829153765164099    -0.021391819479902367 ;
      -0.008556727791960947       -0.020709925973203154    -0.005829153765164099       0.012648088832156207 ...
      -0.005829153765164099       -0.020709925973203154    -0.008556727791960947;
      -0.0014261212986601578      -0.008556727791960947    -0.021391819479902367      -0.028522425973203154...      
      -0.021391819479902367       -0.008556727791960947    -0.0014261212986601578];

g1= [   0.00010448733363597687   0.000835898669087815      0.0029256453418073525     0.005851290683614705      0.007314113354518382...
        0.005851290683614705     0.0029256453418073525     0.000835898669087815      0.00010448733363597687; 
        0.000835898669087815     0.0036070965270211808     0.004924605780370786      0.0006089330836975557    -0.0030889496774797283...     
        0.0006089330836975557    0.004924605780370786      0.0036070965270211808     0.000835898669087815; 
        0.0029256453418073525    0.004924605780370786     -0.006742323964549725     -0.024480422412618347     -0.03147827601901037...      
       -0.024480422412618347    -0.006742323964549725      0.004924605780370786      0.0029256453418073525;
        0.005851290683614705     0.0006089330836975557    -0.024480422412618347     -0.06732496269441629      -0.09617379576343019  ...   
       -0.06732496269441629     -0.024480422412618347      0.0006089330836975557     0.005851290683614705 ; 
        0.007314113354518382    -0.0030889496774797283    -0.03147827601901037      -0.09617379576343019       0.849802834447164 ...
       -0.09617379576343019     -0.03147827601901037      -0.0030889496774797283     0.007314113354518382; 
        0.005851290683614705     0.0006089330836975557    -0.024480422412618347     -0.06732496269441629      -0.09617379576343019...
       -0.06732496269441629     -0.024480422412618347      0.0006089330836975557     0.005851290683614705  ; 
        0.0029256453418073525    0.004924605780370786     -0.006742323964549725     -0.024480422412618347     -0.03147827601901037 ...
       -0.024480422412618347    -0.006742323964549725      0.004924605780370786      0.0029256453418073525;
        0.000835898669087815     0.0036070965270211808     0.004924605780370786      0.0006089330836975557    -0.0030889496774797283 ...    
        0.0006089330836975557    0.004924605780370786      0.0036070965270211808     0.000835898669087815;
        0.00010448733363597687   0.000835898669087815      0.0029256453418073525     0.005851290683614705      0.007314113354518382...
        0.005851290683614705     0.0029256453418073525     0.000835898669087815      0.00010448733363597687 ];
        
 % normalize filters
 
 h0 = h0 ;
 h1 = h1./2 ;
      
 g0 = g0./2;
 g1 = g1;
        
case 'maxflat'        
 % Quasi-tight frame filters, frame bounds A=.97 and B=1
 
h0=[-7.900496718847182e-07 0. 0.000014220894093924927 0.000025281589500310983 -0.000049773129328737247 -0.00022753430550279883 -0.00033182086219158167; 
           0               0              0                   0                       0                          0                     0;
   0.000014220894093924927 0. -0.0002559760936906487 -0.00045506861100559767   0.0008959163279172705   0.004095617499050379    0.00597277551944847;
   0.000025281589500310983 0. -0.00045506861100559767 0.0009765625             0.0015927401385195919  -0.0087890625           -0.01795090623402861;
  -0.000049773129328737247 0.  0.0008959163279172705  0.0015927401385195919   -0.0031357071477104465  -0.014334661246676327   -0.020904714318069645;
  -0.00022753430550279883  0.  0.004095617499050379  -0.0087890625            -0.014334661246676327    0.0791015625            0.16155815610625748;
  -0.00033182086219158167  0.  0.00597277551944847   -0.01795090623402861     -0.020904714318069645    0.16155815610625748     0.3177420190660832];

g0=[-6.391587676622346e-010             0.                1.7257286726880333e-08    3.067962084778726e-08   -1.3805829381504267e-07  -5.522331752601707e-07 ...
    -3.3747582932565985e-07    1.9328161134105974e-06     5.6949046198705095e-06    7.649452131381623e-06;
            0.                          0.                      0.                          0.               0.  0.  0.  0.  0.  0. ;
     1.7257286726880333e-08             0.               -4.65946741625769e-07     -8.283497628902559e-07    3.727573933006152e-06    0.000014910295732024608 ... 
     9.111847391792816e-06    -0.000052186035062086126   -0.00015376242473650378   -0.00020653520754730382;
     3.067962084778726e-08              0.               -8.283497628902559e-07    -1.2809236054493144e-06   6.6267981031220475e-06   0.00002305662489808766 ...
     0.000010064497559808503  -0.0000806981871433068     -0.00021814634152337594   -0.00028666046030363884;
    -1.3805829381504267e-07             0.                3.727573933006152e-06     6.6267981031220475e-06  -0.000029820591464049215 -0.00011928236585619686 ...
    -0.00007289477913434253    0.000417488280496689       0.0012300993978920302     0.0016522816603784306;
    -5.522331752601707e-07              0.                0.000014910295732024608   0.00002305662489808766  -0.00011928236585619686  -0.00041501924816557786 ...
    -0.00018116095607655303    0.0014525673685795225      0.0039266341474207675     0.005159888285465499; 
    -3.3747582932565985e-07             0.                9.111847391792816e-06     0.000010064497559808503 -0.00007289477913434253 -0.00018116095607655303 ...
     0.001468581806076247      0.0006340633462679356     -0.01181401175635013      -0.021745034491193898;
     1.9328161134105974e-06             0.               -0.000052186035062086126  -0.0000806981871433068    0.000417488280496689    0.0014525673685795225 ...
     0.0006340633462679356    -0.005083985790028328      -0.013743219515972684     -0.018059608999129246;
     5.6949046198705095e-06             0.               -0.00015376242473650378   -0.00021814634152337594   0.0012300993978920302   0.0039266341474207675 ...
    -0.01181401175635013      -0.013743219515972684       0.0826466923977296        0.1638988884584603;
     7.649452131381623e-06              0.               -0.00020653520754730382   -0.00028666046030363884   0.0016522816603784306   0.005159888285465499 ...
    -0.021745034491193898     -0.018059608999129246       0.1638988884584603        0.31358726209239235];
 

g1=[-7.900496718847182e-07    0.      0.000014220894093924927 0.000025281589500310983 -0.000049773129328737247 -0.00022753430550279883 -0.00033182086219158167;
            0                 0                0                0                            0                       0                       0                ;
     0.000014220894093924927  0.     -0.0002559760936906487  -0.00045506861100559767   0.0008959163279172705    0.004095617499050379    0.00597277551944847   ;
     0.000025281589500310983  0.     -0.00045506861100559767 -0.0009765625             0.0015927401385195919    0.0087890625            0.01329909376597139   ;
    -0.000049773129328737247  0.      0.0008959163279172705   0.0015927401385195919   -0.0031357071477104465   -0.014334661246676327   -0.020904714318069645  ;
    -0.00022753430550279883   0.      0.004095617499050379    0.0087890625            -0.014334661246676327    -0.0791015625           -0.1196918438937425    ;
    -0.00033182086219158167   0.      0.00597277551944847     0.01329909376597139     -0.020904714318069645    -0.1196918438937425      0.8177420190660831    ]; 

h1=[6.391587676622346e-010       0.                 -1.7257286726880333e-08          -3.067962084778726e-08     1.3805829381504267e-07  5.522331752601707e-07 ...
    3.3747582932565985e-07 -1.9328161134105974e-06  -5.6949046198705095e-06          -7.649452131381623e-06;
          0.                     0.                           0.                            0.                      0.                      0. 0. 0. 0. 0.;
   -1.7257286726880333e-08       0.                  4.65946741625769e-07             8.283497628902559e-07    -3.727573933006152e-06   -0.000014910295732024608 ...
   -9.111847391792816e-06   0.000052186035062086126  0.00015376242473650378           0.00020653520754730382;
   -3.067962084778726e-08        0.                  8.283497628902559e-07           -2.9917573832012203e-07   -6.6267981031220475e-06   5.3851632897621965e-06 ...
    0.00004049868144081346 -0.00001884807151416769  -0.00023692226948222173          -0.0003769812640795245;
    1.3805829381504267e-07       0.                 -3.727573933006152e-06           -6.6267981031220475e-06    0.000029820591464049215  0.00011928236585619686 ...
    0.00007289477913434253 -0.000417488280496689    -0.0012300993978920302           -0.0016522816603784306; 
    5.522331752601707e-07        0.                 -0.000014910295732024608          5.3851632897621965e-06    0.00011928236585619686  -0.00009693293921571956 ...
   -0.0007289762659346422   0.00033926528725501844   0.004264600850679991             0.006785662753431441; 
    3.3747582932565985e-07       0.                 -9.111847391792816e-06            0.00004049868144081346    0.00007289477913434253  -0.0007289762659346422 ...
   -0.001468581806076247    0.002551416930771248     0.01181401175635013              0.017093222023136675;  
   -1.9328161134105974e-06       0.                  0.000052186035062086126         -0.00001884807151416769   -0.000417488280496689     0.00033926528725501844 ... 
    0.002551416930771248   -0.0011874285053925643   -0.01492610297737997             -0.023749819637010044; 
   -5.6949046198705095e-06       0.                  0.00015376242473650378          -0.00023692226948222173   -0.0012300993978920302    0.004264600850679991 ... 
    0.01181401175635013    -0.01492610297737997     -0.0826466923977296              -0.12203257624594532;
   -7.649452131381623e-06        0.                  0.00020653520754730382          -0.0003769812640795245    -0.0016522816603784306    0.006785662753431441 ...
    0.017093222023136675   -0.023749819637010044    -0.12203257624594532               0.821896776039774];
  

g0 = [g0   fliplr(g0(:,1:end-1))];
g0 = [g0 ; flipud(g0(1:end-1,:))];
h0 = [h0   fliplr(h0(:,1:end-1))];
h0 = [h0 ; flipud(h0(1:end-1,:))];

g1 = [g1   fliplr(g1(:,1:end-1))];
g1 = [g1 ; flipud(g1(1:end-1,:))];
h1 = [h1   fliplr(h1(:,1:end-1))];
h1 = [h1 ; flipud(h1(1:end-1,:))]; 

 
case 'pyr'   
    % these filters are very short and very close tight
    h0 = [-0.003236043456039806 -0.012944173824159223 -0.019416260736238835;
          -0.012944173824159223  0.0625                0.15088834764831843 ;
          -0.019416260736238835  0.15088834764831843   0.3406092167691145];
      
    g1 = [-0.003236043456039806 -0.012944173824159223 -0.019416260736238835;
          -0.012944173824159223 -0.0625               -0.09911165235168155 ;
          -0.019416260736238835 -0.09911165235168155   0.8406092167691145];
    
    g0 = [ -0.00016755163599004882 -0.001005309815940293 -0.002513274539850732 -0.003351032719800976;  
           -0.001005309815940293 -0.005246663087920392 -0.01193886400821893    -0.015395021472477663;
           -0.002513274539850732 -0.01193886400821893   0.06769410071569153     0.15423938036811946 ;
           -0.003351032719800976 -0.015395021472477663  0.15423938036811946     0.3325667382415921];
       
    h1 = [  0.00016755163599004882 0.001005309815940293   0.002513274539850732  0.003351032719800976;
            0.001005309815940293  -0.0012254238241592198 -0.013949483640099517 -0.023437500000000007;
            0.002513274539850732  -0.013949483640099517  -0.06769410071569153  -0.10246268507148255;
            0.003351032719800976  -0.023437500000000007  -0.10246268507148255   0.8486516952966369];
        
   g0 = [g0   fliplr(g0(:,1:end-1))];
   g0 = [g0 ; flipud(g0(1:end-1,:))];
   h0 = [h0   fliplr(h0(:,1:end-1))];
   h0 = [h0 ; flipud(h0(1:end-1,:))];

   g1 = [g1   fliplr(g1(:,1:end-1))];
   g1 = [g1 ; flipud(g1(1:end-1,:))];
   h1 = [h1   fliplr(h1(:,1:end-1))];
   h1 = [h1 ; flipud(h1(1:end-1,:))]; 
   
case 'pyrexc' 
        % these filters are very short and very close tight
    h0 = [-0.003236043456039806 -0.012944173824159223 -0.019416260736238835;
          -0.012944173824159223  0.0625                0.15088834764831843 ;
          -0.019416260736238835  0.15088834764831843   0.3406092167691145];
      
    h1 = [-0.003236043456039806 -0.012944173824159223 -0.019416260736238835;
          -0.012944173824159223 -0.0625               -0.09911165235168155 ;
          -0.019416260736238835 -0.09911165235168155   0.8406092167691145];
    
    g0 = [ -0.00016755163599004882 -0.001005309815940293 -0.002513274539850732 -0.003351032719800976;  
           -0.001005309815940293 -0.005246663087920392 -0.01193886400821893    -0.015395021472477663;
           -0.002513274539850732 -0.01193886400821893   0.06769410071569153     0.15423938036811946 ;
           -0.003351032719800976 -0.015395021472477663  0.15423938036811946     0.3325667382415921];
       
    g1 = [  0.00016755163599004882 0.001005309815940293   0.002513274539850732  0.003351032719800976;
            0.001005309815940293  -0.0012254238241592198 -0.013949483640099517 -0.023437500000000007;
            0.002513274539850732  -0.013949483640099517  -0.06769410071569153  -0.10246268507148255;
            0.003351032719800976  -0.023437500000000007  -0.10246268507148255   0.8486516952966369];
        
   g0 = [g0   fliplr(g0(:,1:end-1))];
   g0 = [g0 ; flipud(g0(1:end-1,:))];
   h0 = [h0   fliplr(h0(:,1:end-1))];
   h0 = [h0 ; flipud(h0(1:end-1,:))];

   g1 = [g1   fliplr(g1(:,1:end-1))];
   g1 = [g1 ; flipud(g1(1:end-1,:))];
   h1 = [h1   fliplr(h1(:,1:end-1))];
   h1 = [h1 ; flipud(h1(1:end-1,:))]; 
end